package com.yunlankeji.stemcells.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.model.request.Personal_space;
import com.yunlankeji.stemcells.model.request.Personal_space_fans;

import java.util.List;

public class Fragment_personal_space_fansAdapter extends RecyclerView.Adapter<Fragment_personal_space_fansAdapter.MyViewHolder> {

    private List<Personal_space_fans>personal_space_fansList;

    public Fragment_personal_space_fansAdapter(List<Personal_space_fans> personal_space_fansList) {
        this.personal_space_fansList = personal_space_fansList;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemview = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_item_personal_space_fans,parent,false);
        MyViewHolder myViewHolder=new MyViewHolder(itemview);
        return myViewHolder;

    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Personal_space_fans personal_space_fans=personal_space_fansList.get(position);
        holder.name.setText(personal_space_fans.getName());
        holder.time.setText(personal_space_fans.getTime());
        holder.followType.setText(personal_space_fans.getFolloeType());
        holder.head.setImageResource(personal_space_fans.getHeadId());
    }

    @Override
    public int getItemCount() {
        return personal_space_fansList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        TextView name;
        TextView time;
        TextView followType;
        ImageView head;

        public MyViewHolder(View itemView) {
            super(itemView);
            this.name = itemView.findViewById(R.id.personal_space_fans_name_tx);
            this.time = itemView.findViewById(R.id.personal_space_fans_time_tx);
            this.followType = itemView.findViewById(R.id.personal_space_fans_Type);
            this.head = itemView.findViewById(R.id.iv_mine_personal_space_fans);
        }
    }
}
